import { defineStore } from 'pinia'
import { getBannerList } from '../api/getBanner'
import { getWaterFallList } from '../api/getWaterFall'

// type BannerListData = {
//   BannerList: navListData[]
// }

export const useBannerListStore = defineStore('BannerList', {
  state(): any {
    return {
      BannerList: [],
      WaterFallList: []
    }
  },
  actions: {
    async getBannerList() {
      const res = await getBannerList()
      for (let i = 0; i < res.data.navList.length / 2; i++) {
        const item = res.data.navList.slice(i * 2, i * 2 + 2)
        this.BannerList.push(item)
      }
    },

    async getWaterFallList(page: any, size: any) {
      const res = await getWaterFallList(page, size)
      res.data.result.forEach((item: any) => {
        this.WaterFallList = [...this.WaterFallList, item.look, ...item.topics]
      })
    }
  }
})
